package me.luger.project.fof.controller.api;

import me.luger.core.commom.util.LogUtil;
import me.luger.core.mvc.controller.BaseController;
import me.luger.core.mvc.entity.Result;
import me.luger.project.fof.service.ProductTypeService;
import me.luger.project.fof.entity.ProductType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ProductType controller
 */
@Controller
@RequestMapping("/api/fof/productType")
public class ProductTypeApiController extends BaseController {

    @Autowired
    private ProductTypeService productTypeService;


    @RequestMapping(value = "/fofTypeList",name = "获取FOF类型选择")
    @ResponseBody
    public Object fofTypeList(){
        Map<String,Object> result = new HashMap<String,Object>();
        try{
            List<ProductType> productType1List = productTypeService.getTypeByProfitId(1);
            List<ProductType> productType2List = productTypeService.getTypeByProfitId(2);

            List<Map<String,Object>> productTypeMapList = new ArrayList<Map<String, Object>>();

            Map<String,Object> productTypeItemMap = new HashMap<String,Object>();
            productTypeItemMap.put("id",1);
            productTypeItemMap.put("name","绝对收益");
            productTypeItemMap.put("list",productType1List);
            productTypeMapList.add(productTypeItemMap);

            productTypeItemMap = new HashMap<String,Object>();
            productTypeItemMap.put("id",2);
            productTypeItemMap.put("name","相对收益");
            productTypeItemMap.put("list",productType2List);
            productTypeMapList.add(productTypeItemMap);

            result.put("fofTypeList",productTypeMapList);

        }catch (Exception e){
            LogUtil.errorLog(e,"fofTypeList error");
            return Result.error();
        }
        return Result.success(result);
    }

    @RequestMapping(value = "",name = "接口描述")
    @ResponseBody
    public Object demo(){
        try{

        }catch (Exception e){
            return Result.error();
        }
        return Result.success();
    }
}
